﻿@model Senac.ProjetoIntegrador.Model.Usuario

@{
    Layout = "~/Views/Shared/_LayoutLogin.cshtml";
}

@{
    ViewBag.Title = "Login";
}

<h2>Login</h2>

@using (Html.BeginForm("Login", "Usuario", FormMethod.Post, new {id = "FrmLoginUsuario" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>UsuarioModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.desc_login_email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.desc_login_email)
            @Html.ValidationMessageFor(model => model.desc_login_email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.desc_senha)
        </div>
        <div class="editor-field">
            @Html.PasswordFor(model => model.desc_senha)
            @Html.ValidationMessageFor(model => model.desc_senha)
        </div>
         
        <p>
            <input type="submit" value="Entrar" onclick="FctEntrarLogin();" />
        </p>
    </fieldset>
}

<script type="text/javascript">
    function FctEntrarLogin() {
        if ($("#FrmLoginUsuario").validate().form()) {
            $.ajax({
                url: '@Url.Content("~/Usuario/Login/")',
                type: 'POST',
                data: $("#FrmLoginUsuario").serialize(),
                success: function () {
                    alert("Salvo com sucesso");
                }
            });
        }
    }
</script> 